package com.zmm.common.redis.lock;

import com.zmm.common.redis.key.RedisKey;

/**
 * @author 900045
 * @description:
 * @name ReentrantKey
 * @date By 2021-06-22 14:26:35
 */
public enum ReentrantKey implements RedisKey {

	/**
	 * 自定义锁
	 */
	HELLO_MY_LOCK("MY_LOCK"),
	;

	private String lockKey;

	ReentrantKey() {
		lockKey = this.name();
	}

	ReentrantKey(String key) {
		this.lockKey = key;
	}

	@Override
	public String getKey() {
		String suffix = getSuffix();
		if (suffix == null) {
			return lockKey;
		}
		return new StringBuilder(this.lockKey).append(SEPARATE).append(suffix).toString();
	}
}
